package com.lagou.myfilter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @author zhangxuyuan
 * @version 1.0
 * @date 2020/12/18
 */
@Activate(group = {CommonConstants.CONSUMER})
public class TPFilter implements Filter {
    /**
     * Does not need to override/implement this method.
     *
     * @param invoker
     * @param invocation
     */
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        long   startTime  = System.currentTimeMillis();
        Result invoke = invoker.invoke(invocation);
        long  endtime = System.currentTimeMillis();
        TPRecord.addRecord(invocation.getMethodName(),endtime-startTime);
        return invoke;
    }
}
